import Cookies from 'js-cookie'
// 用户 token
const tokenKey = 'x-authorization-o-token'
export const getToken = () => Cookies.get(tokenKey)
export const setToken = (token: string) => Cookies.set(tokenKey, token)
export const removeToken = () => Cookies.remove(tokenKey)

// 用户信息
const userInfoKey = 'x-authorization-o-userInfo'
export const getUserInfo = () => (Cookies.get(userInfoKey) ? JSON.parse(Cookies.get(userInfoKey) as string) : {})

export const setUserInfo = (userInfo: any) => Cookies.set(userInfoKey, JSON.stringify(userInfo))

// 菜单折叠状态
const collapsibleKey = 'x-authorization-o-collapsible'
export const getCollapsible = () => localStorage.getItem(collapsibleKey) || ''
export const setCollapsible = (collapsible: string) => localStorage.setItem(collapsibleKey, collapsible)

// 选择平台
const platformKey = 'x-authorization-o-platform'
export const getPlatformKey = () => Cookies.get(platformKey)
export const setPlatformKey = (platformKeyValue: string) => Cookies.set(platformKey, platformKeyValue)
